<?php

namespace Settings;

use Zend\Db\TableGateway\TableGateway;
use Zend\Db\ResultSet\HydratingResultSet;

class Module {

    public function getAutoloaderConfig() {
        return array(
            'Zend\Loader\ClassMapAutoloader' => array(
                __DIR__ . '/autoload_classmap.php',
            ),
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                ),
            ),
        );
    }

    public function getConfig() {
        return include __DIR__ . '/config/module.config.php';
    }

    public function getServiceConfig() {
        return array(
            'factories' => array(

                'Settings\Model\SettingsTable' => function($sm) {
                    $tableGateway = $sm->get('SettingsTableGateway');
                    $settingsTable = new Model\SettingsTable($tableGateway);
                    return $settingsTable;
                },
                'SettingsTableGateway' => function($sm) {
                    $adapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new HydratingResultSet();
                    return new TableGateway('variable', $adapter, null, $resultSetPrototype);
                }
            ),
        );
    }

}